$(function () {
    $('.btn_rgister').click(function () {
        var mobile = $(".text[name='mobile']").val();
        var nick_name = $(".text[name='nick_name']").val();
        var password = $(".text[name='password']").val();
        var re_password = $(".text[name='re_password']").val();
        var email = $(".text[name='email']").val();
        var image_code = $(".Recommend_text[name='image_code']").val();
        if (!nick_name) {
            alert("请输入用户名");
            return;
        }
        if (!password) {
            alert("请输入密码");
            return;
        } else if (password.length < 6) {
            alert("密码长度不够6位");
            return;
        }
        if (password != re_password) {
            alert("两次密码不同");
            return;
        }
        if (!email) {
            alert("请输入邮箱");
            return;
        }
        if (!image_code) {
            alert("请输入图片验证码");
            return;
        }
        var params = {
            'mobile': mobile,
            'nick_name': nick_name,
            'password': password,
            'email': email,
            'image_code': image_code,
        };
        $.ajax({
            url: "/passport/registered",
            type: "post",
            data: JSON.stringify(params),
            contentType: "application/json",
            success: function (resp) {
                if (resp.errno == "0") {
                    alert(resp.errmsg)
                } else {
                    alert(resp.errmsg)
                }
            }
        })
    })
});